package skiplist;

import static org.junit.Assert.*;
import junit.framework.Assert;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class TestSkipList {

	private static final int MAX_LEVEL = 3;
	private static final boolean USE_MAX_LEVEL = false;
	private static int ELEMENTS = 50;
	private SkipList list;
		
	@Before
	public void setUp() throws Exception {
		list = new SkipListImpl(MAX_LEVEL, USE_MAX_LEVEL);
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testSkipList() {
		Assert.assertEquals("<ROOT,3>(NIL)", list.printSkipList());
		list.insert(2, 2, 1);
		Assert.assertEquals("<ROOT,3>(2) <2,1>(NIL)", list.printSkipList());
		list.insert(1, 1, 1);
		Assert.assertEquals("<ROOT,3>(1) <1,1>(2) <2,1>(NIL)", list.printSkipList());
		list.insert(8, 8, 2);
		Assert.assertEquals("<ROOT,3>(1,8) <1,1>(2) <2,1>(8) <8,2>(NIL,NIL)", list.printSkipList());
		list.insert(4, 4, 1);
		Assert.assertEquals("<ROOT,3>(1,8) <1,1>(2) <2,1>(4) <4,1>(8) <8,2>(NIL,NIL)", list.printSkipList());
		list.remove(2);
		Assert.assertEquals("<ROOT,3>(1,8) <1,1>(4) <4,1>(8) <8,2>(NIL,NIL)", list.printSkipList());
	}

}
